package com.example.javatwo.controller.xs.wjy;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.javatwo.pojo.xs.wjy.Historycheck;
import com.example.javatwo.pojo.xs.wjy.Quotation;
import com.example.javatwo.pojo.xs.wjy.Quotationes;
import com.example.javatwo.service.xs.wjy.IquotationBizImpl;

@Controller
public class Contre {
	@Autowired
	private IquotationBizImpl quotationbizimpl;

	@RequestMapping("/wjylist")
	@ResponseBody
	public Quotation wjyqueryall(String deletedstate, Integer page) throws Exception {
		return quotationbizimpl.fundInfo(deletedstate, page);
	}

	@RequestMapping("/xsbjd")
	public String list() throws Exception {
		return "/xs/wjy/xsbjd";
	}

	@RequestMapping("/wjyfindlist")
	@ResponseBody
	public List<Quotation> wjyqueryalllist() throws Exception{
		return quotationbizimpl.findquotationlist();
	}

	@RequestMapping("/wjysave")
	@ResponseBody
	public String save(@RequestBody Quotation quotation) throws Exception{
		System.out.println(quotation);
		try {
			quotationbizimpl.savequotation(quotation);
			return "保存成功";
		} catch (RuntimeException e) {
			// TODO: handle exception
			return "不能保存";
		}
		
		
	}

	@RequestMapping("/wjyupdate")
	@ResponseBody
	public String update(@RequestBody Quotation quotation) throws Exception{

		try {
			quotationbizimpl.updatequotation(quotation);
			return "修改成功";
		} catch (RuntimeException e) {
			// TODO: handle exception
			return "你已经审核过了不能修改";
		}
		
	
	}

	@RequestMapping("/wjydelete")
	@ResponseBody
	public String delete(@RequestBody String billno) throws Exception{
		System.out.println(billno);
		try {
			quotationbizimpl.deletequotation("已删除", billno);
			return "删除成功";
		} catch (RuntimeException e) {
			// TODO: handle exception
			return "你已经审核过了,不能删除";
		}
		
	}

	@RequestMapping("/wjyshenhe")
	@ResponseBody
	public String shenhe(@RequestBody String billno) throws Exception{
		try {
			System.out.println(billno);
			quotationbizimpl.wjyshenhe(billno);
			return "审核成功";
		} catch (RuntimeException e) {

			// TODO: handle exception
			return "你已经审核过了";
		}

	}

	@RequestMapping("/wjyfanshenhe")
	@ResponseBody
	public String fanshenhe(@RequestBody String billno) throws Exception{

		try {

			quotationbizimpl.wjyfanshenhe(billno);
			return "反审核成功";
		} catch (RuntimeException e) {

			// TODO: handle exception
			return "你没有审核过,不能反审核";
		}

	}
	@RequestMapping("/lsjycx")
	public String lsjycx()throws Exception{
		return "/xs/wjy/lsjycx";
	}
	@RequestMapping("/lsjycxasdsa")
	@ResponseBody
	public List<Historycheck> loadquotationcust( String formalcust){
		System.out.println(formalcust);
		return quotationbizimpl.loadquotationcust(formalcust);
	}
}
